 package sza.oracle.apps.ap.oie.entry.header.webui;
 
 import java.io.PrintStream;
 import oracle.apps.ap.oie.entry.header.webui.HeaderKffCO;
 import oracle.apps.ap.oie.server.ExpenseReportHeadersVOImpl;
 import oracle.apps.ap.oie.server.ExpenseReportHeadersVORowImpl;
 import oracle.apps.ap.oie.webui.NavigationUtility;
 import oracle.apps.fnd.common.VersionInfo;
 import oracle.apps.fnd.framework.OAApplicationModule;
 import oracle.apps.fnd.framework.OAViewObject;
 import oracle.apps.fnd.framework.webui.OAPageContext;
 import oracle.apps.fnd.framework.webui.beans.OAWebBean;
 import oracle.apps.fnd.framework.webui.beans.message.OAMessageChoiceBean;
 import oracle.jbo.Row;
 import sza.oracle.apps.ap.oie.lov.server.DeptApproverVOImpl;
 import sza.oracle.apps.ap.oie.utility.SzaOIEUtil;
 
 public class SzaHeaderKffCO extends HeaderKffCO
 {
   public static final String RCS_ID = "$Header$ R12.1.3";
   public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header$ R12.1.3", "%packagename%");
 
   public void processRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderKffCO.processRequest";
 
     LogMessage = "SZA SzaHeaderKffCO.processRequest - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     SzaOIEUtil.printContextParameter(pageContext, webBean);
 
     SzaOIEUtil.printContextTransaction(pageContext, webBean);
 
     SzaOIEUtil.printContextSession(pageContext, webBean);
 
     super.processRequest(pageContext, webBean);
 
     processSzaDeptApproverChange(pageContext, webBean);
 
     LogMessage = "SZA SzaHeaderKffCO.processRequest - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 
   public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderKffCO.processFormRequest";
 
     SzaOIEUtil.printContextParameter(pageContext, webBean);
 
     SzaOIEUtil.printContextTransaction(pageContext, webBean);
 
     SzaOIEUtil.printContextSession(pageContext, webBean);
 
     LogMessage = "SZA SzaHeaderKffCO.processFormRequest - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String TemplateId = (String)pageContext.getTransactionValue("TemplateId");
 
     LogMessage = "SZA SzaHeaderKffCO.processFormRequest - TemplateId:" + TemplateId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String CurrentPage = NavigationUtility.getCurrentPage(pageContext);
     LogMessage = "SZA SzaButtonsCO.processFormRequest - CurrentPage:" + CurrentPage;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String event = pageContext.getParameter("event");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - event:" + event;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String source = pageContext.getParameter("source");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - source:" + source;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String LovInputSourceId = pageContext.getLovInputSourceId();
 
     if (("GeneralInformationPG".equalsIgnoreCase(CurrentPage)) && (("lovUpdate".equals(event)) || ("lovValidate".equals(event))))
     {
       if (LovInputSourceId.equalsIgnoreCase("KffSEGMENT2"))
       {
         LogMessage = "SZA CostCenterChange";
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         processSzaDeptApproverChange(pageContext, webBean);
       }
 
       if (LovInputSourceId.equalsIgnoreCase("HeaderDFF9"))
       {
         LogMessage = "SZA CostCenterChange";
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         SplitExpenseHeaderAttribute6(pageContext, webBean);
       }
 
     }
 
     super.processFormRequest(pageContext, webBean);
 
     LogMessage = "SZA SzaHeaderKffCO.processFormRequest - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 
   private void processSzaDeptApproverChange(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderKffCO.processSzaDeptApproverChange";
 
     SzaOIEUtil.printContextParameter(pageContext, webBean);
 
     SzaOIEUtil.printContextTransaction(pageContext, webBean);
 
     SzaOIEUtil.printContextSession(pageContext, webBean);
 
     LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     pageContext.putTransactionValue("IsDeptApproverRequired", "N");
 
     String EmployeeId = (String)pageContext.getTransactionValue("EmployeeId");
 
     LogMessage = "SZA ExpenseTypeTreeCO processRequest - EmployeeId :" + EmployeeId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String CurrentPage = NavigationUtility.getCurrentPage(pageContext);
     LogMessage = "SZA SzaButtonsCO.processFormRequest - CurrentPage:" + CurrentPage;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String event = pageContext.getParameter("event");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - event:" + event;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String source = pageContext.getParameter("source");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - source:" + source;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     OAApplicationModule am = pageContext.getApplicationModule(webBean);
 
     System.out.println("Expense Type AM Name is =>" + am.getFullName());
     String FlexConcatenated = "";
 
     if (pageContext.getParameter("KffSEGMENT2") != null)
     {
       FlexConcatenated = pageContext.getParameter("KffSEGMENT2");
     }
     else
     {
       OAViewObject HeaderVo = (OAViewObject)am.findViewObject("ExpenseReportHeadersVO");
 
       if (HeaderVo != null)
       {
         FlexConcatenated = (String)HeaderVo.getCurrentRow().getAttribute("FlexConcatenated");
       }
 
       LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - FlexConcatenated:" + FlexConcatenated;
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
     }
 
     String EmployeeCompanyCode = SzaOIEUtil.getEmployeeCompanyCode(pageContext, webBean, EmployeeId);
 
     LogMessage = "SZA ExpenseTypeTreeCO processSzaDeptApproverChange - EmployeeCompanyCode :" + EmployeeCompanyCode;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     DeptApproverVOImpl DeptApproverVO1 = (DeptApproverVOImpl)am.findViewObject("DeptApproverVO1");
 
     if (DeptApproverVO1 != null)
     {
       LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - Found VO DeptApproverVO for AM. This means we have re-entered the page.";
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
     }
     else
     {
       LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - CAN NOT FIND VO DeptApproverVO.";
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       DeptApproverVO1 = (DeptApproverVOImpl)am.createViewObject("DeptApproverVO1", "sza.oracle.apps.ap.oie.lov.server.DeptApproverVO");
     }
 
     if (DeptApproverVO1 != null)
     {
       LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - FOUND VO DeptApproverVO for AMO.";
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       DeptApproverVO1.setWhereClauseParams(null);
       DeptApproverVO1.setWhereClauseParam(0, EmployeeCompanyCode);
 
       DeptApproverVO1.setWhereClauseParam(1, FlexConcatenated);
 
       DeptApproverVO1.executeQuery();
 
       OAMessageChoiceBean SzaDeptApprover = (OAMessageChoiceBean)webBean.findIndexedChildRecursive("SzaDeptApprover");
 
       if (SzaDeptApprover != null)
       {
         SzaDeptApprover.setRendered(true);
 
         String IsCCRequireDepApprovert = SzaOIEUtil.getIsCCRequireDepApprovert(pageContext, webBean, FlexConcatenated);
 
         if ("Y".equalsIgnoreCase(IsCCRequireDepApprovert))
         {
           SzaDeptApprover.setAttributeValue(OAMessageChoiceBean.REQUIRED_ATTR, "yes");
 
           pageContext.putTransactionValue("IsDeptApproverRequired", "Y");
         }
         else
         {
           SzaDeptApprover.setAttributeValue(OAMessageChoiceBean.REQUIRED_ATTR, "no");
         }
       }
 
     }
 
     LogMessage = "SZA SzaHeaderKffCO.processSzaDeptApproverChange - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 
   public void SplitExpenseHeaderAttribute6(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderKffCO.SplitExpenseHeaderAttribute6";
     OAApplicationModule am = pageContext.getApplicationModule(webBean);
 
     LogMessage = LogFunction + " - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     ExpenseReportHeadersVOImpl HeaderVo = (ExpenseReportHeadersVOImpl)am.findViewObject("ExpenseReportHeadersVO");
 
     if (HeaderVo != null)
     {
       ExpenseReportHeadersVORowImpl headerRow = (ExpenseReportHeadersVORowImpl)HeaderVo.getCurrentRow();
 
       String Attribute6 = "";
       String Attribute7 = "";
       String Attribute14 = "";
       if (HeaderVo.getCurrentRow().getAttribute("Attribute6") != null)
       {
         Attribute6 = HeaderVo.getCurrentRow().getAttribute("Attribute6").toString();
         LogMessage = "SZA SzaHeaderKffCO.SplitExpenseHeaderAttribute6 - Attribute6:" + Attribute6;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         String[] Attribute6Array = Attribute6.split("\\.");
         int ArrayLegth = Attribute6Array.length;
         LogMessage = LogFunction + " - ArrayLegth:" + ArrayLegth;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         Attribute14 = Attribute6Array[0];
         LogMessage = LogFunction + " - Attribute14:" + Attribute14;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         Attribute7 = Attribute6Array[1];
         LogMessage = LogFunction + " - Attribute7:" + Attribute7;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
       }
       else
       {
         Attribute14 = "";
         LogMessage = LogFunction + " - Attribute14:" + Attribute14;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
       }
 
       HeaderVo.getCurrentRow().setAttribute("Attribute14", Attribute14);
     }
 
     LogMessage = LogFunction + " - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 }



